﻿@using DJY.Code

<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>登录-@(ConfigHelper.SoftName)</title>
    <link href="~/Content/css/framework-font.css" rel="stylesheet" />
    <link href="~/Content/css/framework-login.css" rel="stylesheet" />
    <link rel="shortcut icon" href="~/favicon.ico">
    <script src="~/Content/js/jquery/jquery-2.1.1.min.js"></script>
    <script src="~/Content/js/cookie/jquery.cookie.js"></script>
    <script src="~/Content/js/md5/jquery.md5.js"></script>
    <!--[if lte IE 8]>
        <div id="errorie"><div>您还在使用老掉牙的IE，正常使用系统前请升级您的浏览器到 IE8以上版本 <a target="_blank" href="http://windows.microsoft.com/zh-cn/internet-explorer/ie-8-worldwide-languages">点击升级</a>&nbsp;&nbsp;强烈建议您更改换浏览器：<a href="http://down.tech.sina.com.cn/content/40975.html" target="_blank">谷歌 Chrome</a></div></div>
    <![endif]-->
</head>
<body>
    <div style="position: absolute; z-index: 999; top: 20px; left: 20px; color: #fff; font-size: 13px; line-height: 22px;">
    </div>
    <div class="wrapper">
        <div class="container">
            <div class="logo">
                <h1 style="float:left;margin-top:6px;">@ConfigHelper.SoftName</h1>
            </div>
            <form class="form">
                <div class="row">
                    <input id="txt_account" type="text" placeholder="用户名/手机号/邮箱" value="">
                    <i class="fa fa-user"></i>
                </div>
                <div class="row">
                    <input id="txt_password" type="password" placeholder="登录密码" value="">
                    <i class="fa fa-key"></i>
                </div>
                <div class="row">
                    <input id="txt_code" maxlength="4" type="text" placeholder="验证码" style="width: 190px; float: left;">
                    <div style="width: 110px; float: right; padding-top: 14px; padding-left: 14px;">
                        看不清？<a id="switchCode" href="javascript:void(0);" style="text-decoration: none;">换一张</a>
                        <img id="imgcode" class="authcode" src="~/Login/GetAuthCode" width="80" height="25" />
                    </div>
                </div>
                <div class="row">
                    <button id="login_button" type="button"><span>登录</span></button>
                </div>
                <div class="row">
                </div>
            </form>
            <div class="login_tips"></div>
        </div>
        <ul class="bg-bubbles">
            <li></li>
            <li></li>
            <li></li>
            <li></li>
            <li></li>
            <li></li>
            <li></li>
            <li></li>
            <li></li>
            <li></li>
        </ul>
    </div>
    <div class="copyright">
        @ConfigHelper.Vendor 版权所有 Copyright@@@DateTime.Now.Year @ConfigHelper.Version
    </div>
    <script type="text/javascript">
        function formMessage(msg) {
            $('.login_tips').find('.tips_msg').remove();
            $('.login_tips').append('<div class="tips_msg"><i class="fa fa-question-circle"></i>' + msg + '</div>');
        }

        $(function () {
            $('.wrapper').height($(window).height());
            $(".container").css("margin-top", ($(window).height() - $(".container").height()) / 2 - 50);
            $(window).resize(function (e) {
                $('.wrapper').height($(window).height());
                $(".container").css("margin-top", ($(window).height() - $(".container").height()) / 2 - 50);
            });
            $("#switchCode").click(function () {
                $("#imgcode").attr("src", "/Login/GetAuthCode?time=" + Math.random());
            });
            $("#login_button").click(function () {
                var $username = $("#txt_account");
                var $password = $("#txt_password");
                var $code = $("#txt_code");
                if ($username.val() == "") {
                    $username.focus();
                    formMessage('请输入用户名/手机号/邮箱。');
                    return false;
                }
                if ($password.val() == "") {
                    $password.focus();
                    formMessage('请输入登录密码。');
                    return false;
                }
                if ($code.val() == "") {
                    $code.focus();
                    formMessage('请输入验证码。');
                    return false;
                }

                $("#login_button").attr('disabled', 'disabled').find('span').html("loading...");
                $.ajax({
                    url: "/Login/CheckLogin",
                    data: { username: $.trim($username.val()), password: $.trim($password.val()), code: $.trim($code.val()) },
                    type: "post",
                    dataType: "json",
                    success: function (data) {
                        if (data.state == "success") {
                            $("#login_button").find('span').html("登录成功，正在跳转...");
                            window.location.href = "/Home/Index";
                        } else {
                            $("#login_button").removeAttr('disabled').find('span').html("登录");
                            $("#switchCode").trigger("click");
                            $code.val('');
                            formMessage(data.message);
                        }
                    }
                });
            });
            document.onkeydown = function (e) {
                if (!e) e = window.event;
                if ((e.keyCode || e.which) == 13) {
                    document.getElementById("login_button").focus();
                    document.getElementById("login_button").click();
                }
            }
        });
    </script>
</body>
</html>
